Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@esmj/observable

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@esmj/observable

Tiny observable library for other extensibility

  • 0.0.5
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
19
increased by58.33%
Maintainers
1
Weekly downloads
 
Created
Source

Observable

The @esmj/observable is tiny observable library for other extensibility.

Requirements

  • Node 18+

Install

npm install @esmj/observable

Usage

It works for both Javascript modules (ESM and CJS).

import { Observable, IObservable, IObserver } from '@esmj/monitor';

const observer: IObserver = {
  next(value) {
    console.log(value);
  }
}

const observable: IObservable = new Observable();

const unsubscribe = observable.subscribe(observer);

observable.next('Hello world'); // log: Hello world

unsubscribe();

API

observable = new Observable()

Create a new instance of Observable.

pipe(...rest: ((observable) => observable)[])

Extends default observable logic.

next(...rest: any[])

Monitoring start measure node metric.

complete(...rest: any[])

Monitoring stop measure node metric.

error(...rest: any[])

Monitoring start measure node metric.

subscribe(observer)

Subscribe observer.

Returns an unsubscribe method.

observer

Type: () => void | { next: () => void, error?: () => void, complete?: () => void}

unsubscribe(observer)

Remove observer.

observer

Type: () => void | { ?next: () => void, error?: () => void, complete?: () => void}

Keywords

FAQs

Package last updated on 03 Dec 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc